{include file="common/head"/}
<style>
    .layui-table-cell{height: auto;}
    .layui-table-cell ul li a{color: #1C8FEF;display: block;border: 1px solid #ececec;padding: 3px 8px;}
    .layui-table-cell ul li a:hover{color: #005580}
</style>
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>审核员列表</legend>
    </fieldset>
    <blockquote class="layui-elem-quote">
        <a href="/admin/check/check_search.html" class="layui-btn layui-btn-sm">添加审核员</a>
        <div class="layui-inline" style="float: right">
            <form class="layui-form" action="">
                <div class="layui-form-item" style="margin-bottom: 0px">
                    <div class="layui-inline" style="margin-right: 0px">
                        <div class="layui-input-inline" style="width: 200px;">
                            <input type="text" id="keyword" name="keyword" autocomplete="off"placeholder="请输入审核员姓名/编号/部门"class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-right: 0px">
                        <div class="layui-btn-group layui-inline" style="margin: 0px">
                            <a  href="{:url('lists')}" class="layui-btn layui-btn-primary">重置</a>
                            <button id="search" class="layui-btn layui-btn-normal" type="button" lay-submit lay-filter="formDemo" style="background-color: #009688;">
                                <i class="layui-icon">&#xe615;</i>查找
                            </button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </blockquote>

    <table class="layui-table" id="list" lay-filter="list"></table>
</div>


<script type="text/html" id="section_ids">
    {{# if(d.is_second!=2){ }}
    所有部门
    {{# }else{ }}
    {{# if(d.section_ids!=null){ }}
    {{d.section_ids}}
    {{# } }}
    {{# } }}
</script>

<script type="text/html" id="is_second">
    {{# if(d.is_second==2){ }}
     一级
    {{# }else{ }}
     二级
    {{# } }}
</script>

<script type="text/html" id="barDemo">
    {{# if(d.is_second==2){ }}
    <button  data-id="{{d.id}}" class="layui-btn layui-btn-xs distribution_section layui-btn-normal">分配部门</button>
    {{# }else{ }}
    <button  class="layui-btn layui-btn-xs layui-btn-disabled">分配部门</button>
    {{# } }}
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">{:lang('del')}</a>
</script>


{include file="common/foot"/}
<script>
    layui.use('table', function() {
        var table = layui.table, $ = layui.jquery;var form = layui.form;
        var tableIn = table.render({
            id: 'user',
            elem: '#list',
            url: "{:url('lists')}",
            method: 'post',
            page: true,
            even:true,
            cols: [[
                {title: '序号', width: 130,style:'height: auto;',type:'numbers'},
                {field: 'teacher_no',title: '审核员工号', width: 150,style:'height: auto;'},
                {field: 'true_name', title: '审核员姓名', width: 150,templet:'#name'},
                {field: 'is_second', title: '审核员级别', width: 100,templet:'#is_second'},
                {field: 'section_ids', title: '审核部门', width: 500,templet:'#section_ids'},
                {field: 'create_time', title: '添加时间', width: 180},
                {width: 250, align: 'center', toolbar: '#barDemo'}
            ]],
            limit: 10 //每页默认显示的数量
        });
        $('#search').on('click', function () {

            var keyword = $('#keyword').val();
            console.log(keyword);
            if ($.trim(keyword) === '') {
                layer.msg('{:lang("pleaseEnter")}查找信息！', {icon: 0});
                return;
            }
            //表格重载
            tableIn.reload({
                //传递额外参数
                where: {keyword: keyword}

            });
        });

        // 配置考核项
        $(document).on('click','.distribution_section',function () {
            var id=$(this).attr('data-id');
            layer.open({
                type:2,
                title: '分配部门',
                shadeClose:true,
                shade:0.3,
                area:['80%','80%'],
                content: '{:url("distribution_section")}?id='+id
            });
        });

        table.on('tool(list)', function(obj){
            var data = obj.data;
            if(obj.event === 'del'){
                layer.confirm('{:lang("Are you sure you want to delete it")}', function(index){
                    $.post("{:url('checkDel')}",{id:data.id},function(res){
                        if(res.code==1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            obj.del();
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }

        });
    });
</script>
</body>
</html>